﻿<UserControl x:Class="WPFInterview.DataBindingQuestion"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:WPFInterview"
    >
    <UserControl.Resources>
        <local:DataBindingTest x:Key="_object"></local:DataBindingTest>
    </UserControl.Resources>
    <Grid Name="_databindingGrid">
        <StackPanel>
            <Slider Name="slider" Minimum="0" Maximum="10"></Slider>
            <Label Height="30">
                <Label.Content>
                    <Binding ElementName="slider" Path="Value"/>
                </Label.Content>
            </Label>
            <Button Foreground="{Binding Source={x:Static SystemColors.WindowColor}}">
                <Button.Content>             
                    <Binding Source="{StaticResource _object}" Path="TestName"></Binding>
                </Button.Content>
            </Button>
            <Button Height="40">
                <Button.Content>
                    <Binding Source="{StaticResource _object}" Path="TestName"></Binding>
                </Button.Content>
            </Button>
            <FlowDocumentScrollViewer>
            <FlowDocument>
                <Paragraph>
                    The term databinding describes the process of creating 
                    a dependence for the value of one propeerty, called the target property,
                    on the value of another value, called the source property using the Binding class
                    <LineBreak></LineBreak>
                    <LineBreak></LineBreak>
                    Important properties of the Binding Class: ElementName, RelativeSource, Mode, Path, Source, XPath etc.
                </Paragraph>
                    <Paragraph>
                        Quick check: When creating a binding, when would you use the Source property? When would you use the ElementName
                        property? When would you use the RelativeSource property? When would you expliccitly use none of those
                        properties at all?                        
                    </Paragraph>
                    <Paragraph>
                        You use the ElementName property to identify another WPF element. You use the 
                        source property to specify an object that is not a WPF element, such as a
                        resource. The RelativeSource property that exists in the visual tree in a relative location.
                        You do not need to specify any of thse if DataContext has been set for the element or for a 
                        visual parent in code.
                    </Paragraph>
                </FlowDocument>
        </FlowDocumentScrollViewer>
        </StackPanel>
    </Grid>
</UserControl>
